<?php

namespace App\Http\Service;

use App\Http\Repository\ActivityLogRepository;
use App\Http\Criteria\OrderByCreatedAtCriteria;

class ActivityLogService extends BaseService
{
    protected $rep;

    public function __construct(ActivityLogRepository $repository)
    {
        $this->rep = $repository;

    }

    public function getLastLog($userId, $isSuccess)
    {
        $this->rep->pushCriteria(new OrderByCreatedAtCriteria());
        return $this->rep->findFirstRowByFields(['user_id' => $userId, 'is_success' => $isSuccess]);
    }
}
